package com.ase.design.工厂模式.抽象工厂;

import java.util.concurrent.*;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author gyhstart
 * @create 2021/5/11 - 22:39
 **/
public class Test {
    public static void main(String[] args) {

//        for (int i = 0; i < 10; i++) {
//            Executors.newFixedThreadPool(3).execute(() -> System.out.println("Id: " + Thread.currentThread().getId() + " ,线程:" + Thread.currentThread().getName()));
//        }

        ExecutorService service = Executors.newSingleThreadExecutor();

//        for (int i = 0; i < 10; i++) {
//            final int index = i;
//            service.execute(() -> {
//                System.out.println("序号" + index + " Id: " + Thread.currentThread().getId() + " ,线程:" + Thread.currentThread().getName());
//                try {
//                    Thread.sleep(1000);
//                } catch (InterruptedException e) {
//                    e.printStackTrace();
//                }
//            });
//        }

        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(10, 15, 100, TimeUnit.SECONDS, new LinkedBlockingQueue<>(90));
//        for (int i = 0; i < 10; i++) {
//            final int index = i;
//            threadPoolExecutor.execute(() -> {
//                System.out.println("序号" + index + " Id: " + Thread.currentThread().getId() + " ,线程:" + Thread.currentThread().getName());
//                try {
//                    Thread.sleep(1000);
//                } catch (InterruptedException e) {
//                    e.printStackTrace();
//                }
//            });
//        }
        new Pools().pool();

    }
}
